<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/8/8
  Time: 21:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <script type="text/javascript" src="/js/jquery-3.4.1.js"></script>
    <script type="text/javascript">
      function reloadCheckImg(){
          //强制刷新：每次请求都传递一个唯一的参数，服务器便知道这是一个新的请求
          $("img").attr("src","img.jsp?t=" + (new Date().getTime()));
      }

      $(document).ready(function(){
        $("#checkcodeId").blur(function(){
            var $checkcode = $("#checkcodeId").val();
            //校验：文本框中输入的值发送到服务端
            //服务端：获取文本框输入的值，和真实验证码图片中的值对比，并返回验证结果
            $.post(
                    "CheckCodeServlet",
                    "checkcode=" + $checkcode,
                    function(result){
                        $("#tip").html(result);
                    }
            );
        });
      });
    </script>
    <title>验证码</title>
  </head>
  <body>
    验证码：
    <input type="text" name="checkcode" id="checkcodeId" size="6" />
    <!--验证码-->
    <a href="javascript:reloadCheckImg()"><img src="img.jsp"></a>
    <br/>
    <span id="tip"></span>
  </body>
</html>
